<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/css/libs/http_cdn.jsdelivr.net_npm_bootstrap@4.6.2_dist_css_bootstrap.css"
          crossorigin="anonymous">
    <link rel="stylesheet" href="/css/main.css">
    <script src="/js/libs/axios.js"></script>
    <script src="/js/libs/vue.js"></script>
    <script src="/js/libs/jq3.6.js"></script>

    <title>控制台</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light tm-0">
    <a class="navbar-brand" href="/">
        <img style="opacity: 0.86;max-width: 50px; border-radius: 999px"
             class="navbar-brand" src="/icon" alt="qq"></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
            aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="/">QQ代挂 <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="http://kloping.top/">kloping's</a>
            </li>
            <li class="nav-item">
                <a class="nav-link disabled">更多功能;敬请期待.</a>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
            <a class="dropdown-item" target="_blank" href="https://github.com/gdpl2112/dg-bot">
                <img style="opacity: 0.86;max-width: 35px" alt="github" loading="lazy"
                     src="https://s.nmxc.ltd/sakurairo_vision/@2.6/display_icon/sora/github.png">
                github 开源地址
            </a>
        </form>
    </div>
</nav>
<br>
<br>
<div class="container tm-0">
    <div class="row">
        <div class="list-group col" id="main-div">
            <div class="list-group-item list-group-item-action" v-for="e in list">
                <div class="input-group">
                    <div class="input-group-prepend">
                        <span class="input-group-text">{{e.qid}}</span>
                    </div>
                    <input :id="'auth-'+e.qid" type="text" class="form-control" :value="e.auth">
                    <div class="input-group-prepend">
                        <span class="input-group-text">exp</span>
                    </div>
                    <input :qid="e.qid" :id="'exp-'+e.qid" type="text" class="form-control i" :value="e.exp">
                </div>
                <div class="input-group">
                    <div class="input-group-prepend">
                        <span class="input-group-text">年</span>
                    </div>
                    <input :qid="e.qid" :id="'year-'+e.qid" type="text" class="form-control o" :value="e.y">
                    <div class="input-group-prepend">
                        <span class="input-group-text">月</span>
                    </div>
                    <input :qid="e.qid" :id="'month-'+e.qid" type="text" class="form-control o" :value="e.m">
                    <div class="input-group-prepend">
                        <span class="input-group-text" id="addon-wrapping">日</span>
                    </div>
                    <input :qid="e.qid" :id="'day-'+e.qid" type="text" class="form-control o" :value="e.d">
                    &nbsp;&nbsp;
                </div>
                <button type="button" class="btn btn-info" v-on:click="modify(e.qid)">修改</button>
            </div>
        </div>
    </div>
</div>
<script>
    let vm1 = new Vue({
        el: "#main-div",
        created: function () {
            axios.get("/m/list").then(function (response) {
                vm1.list = response.data
            }).catch(function (err) {
                alert(err);
            })
        }, data: {
            list: []
        }, methods: {
            modify: function (id) {
                let auth = $("#auth-" + id).val()
                let exp = $("#exp-" + id).val()
                axios.get("/m/modify?qid=" + id + "&auth=" + auth + "&exp=" + exp).then(function (response) {
                    vm1.list = response.data
                    alert("ok")
                }).catch(function (err) {
                    alert(err);
                })
            }
        }
    });
    $(function () {
        $(".o").change(function (e) {
            let qid = $(this).attr("qid")
            let year = $("#year-" + qid).val()
            let month = $("#month-" + qid).val()
            let day = $("#day-" + qid).val()
            axios.get("/m/get-exp?y=" + year + "&m=" + month + "&d=" + day).then(function (response) {
                $("#exp-" + qid).val(response.data)
            }).catch(function (err) {
                alert(err);
            })

        });

        $(".i").change(function (e) {
            let qid = $(this).attr("qid")
            let exp = $("#exp-" + qid).val()
            axios.get("/m/exp-ymd?exp=" + exp).then(function (response) {
                let ds = response.data
                $("#year-" + qid).val(ds[0])
                $("#month-" + qid).val(ds[1])
                $("#day-" + qid).val(ds[2])
            }).catch(function (err) {
                alert(err);
            })
        });
    });
</script>
<script src="/js/utils.js"></script>
<script src="/js/libs/http_cdn.jsdelivr.net_npm_jquery@3.5.1_dist_jquery.slim.min.js" crossorigin="anonymous"></script>
<script src="/js/libs/http_cdn.jsdelivr.net_npm_bootstrap@4.6.2_dist_js_bootstrap.bundle.js"
        crossorigin="anonymous"></script>
</body>
</html>